﻿@namespace Microsoft.FluentUI.AspNetCore.Components
@inherits ListComponentBase<TOption>
@typeparam TOption

<style>
    @($"#{Id}::part(listbox) {{ {(string.IsNullOrEmpty(Height) ? null : $"max-height: {Height};")} z-index: {ZIndex.ComboboxPopup} }}")
</style>

<CascadingValue Value=@_internalListContext Name="ListContext" TValue="InternalListContext<TOption>" IsFixed=true>
    <FluentInputLabel ForId="@Id" Label="@Label" AriaLabel="@AriaLabel" Required="@Required" ChildContent="@LabelTemplate" />
    <fluent-combobox @ref=Element
                     id="@Id"
                     class="@ClassValue"
                     style="@StyleValue"
                     autocomplete="@Autocomplete.ToAttributeValue()"
                     open=@Open
                     current-value=@GetComboboxContent()
                     placeholder=@Placeholder
                     position=@Position.ToAttributeValue()
                     disabled=@Disabled
                     appearance="@Appearance.ToAttributeValue()"
                     required="@Required"
                     @oncomboboxchange="@ChangeHandlerAsync"
                     @oncontrolinput="@InputHandlerAsync"
                     autofocus="@Autofocus"
                     name="@Name"
                     @attributes="AdditionalAttributes">
        @_renderOptions
    </fluent-combobox>
</CascadingValue>
